package cn.gzsxt.service.impl;

import java.util.List;

import cn.gzsxt.dao.ConstractDao;
import cn.gzsxt.dao.impl.ConstractDaoImpl;
import cn.gzsxt.po.Build;
import cn.gzsxt.po.Constract;
import cn.gzsxt.po.Floor;
import cn.gzsxt.po.Room;
import cn.gzsxt.service.ConstractService;

public class ConstractServiceImpl implements ConstractService {
	
	//引入dao层
	private ConstractDao dao = new ConstractDaoImpl();
	
	@Override
	public List<Build> getBuild() {
		return dao.getBuild();
	}

	@Override
	public List<Floor> getFloorByBuildId(Integer buildId) {
		return dao.selectFloorByBuildId(buildId);
	}

	@Override
	public List<Room> getRoomByFloorId(Integer floorId) {
		return dao.selectRoomByFloorId(floorId);
	}

	@Override
	public int addConstract(Constract constract) {
		//添加合同到数据库
		int row = dao.insertConstract(constract);
		if(row == 1){
			//修改当前合同对应房间的状态  状态改为1 设为已出租
			row = dao.updateRoomStatus(constract.getRoom_id());
		}
		return row;
	}

}
